#pragma once
#include "IStack.h"
#include "ILayer.h"
#include "IProtocol.h"
#include "IContainerType.h"
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>

class CStackOSI : public IStack, public IContainerType< std::vector<boost::shared_ptr<ILayer> >, boost::shared_ptr<ILayer> >
{
public:
	friend class boost::serialization::access;
	virtual ~CStackOSI(void);
	
	template<class Archive> 
	void serialize(Archive & ar, const unsigned int version) 
	{
		ar & boost::serialization::base_object<IStack>(*this);
		ar & boost::serialization::base_object<IContainerType< std::vector<boost::shared_ptr<ILayer>>, boost::shared_ptr<ILayer> > >(*this);
	}
	
	virtual const boost::shared_ptr<ILayer>& getLayer( const std::string& name ) const;

	virtual void addLayer( const boost::shared_ptr<ILayer>& layer );

	virtual void removeLayer( const std::string& name );

	virtual StackUtils::e_Status Encode(CPacket& packet);

	virtual void add( const boost::shared_ptr<ILayer>& element );

	virtual StackUtils::e_Status Decode( CPacket& packet );

	static CStackOSI& getInstance();

	virtual void init();

private:
	CStackOSI(void);
	CStackOSI& operator=(const CStackOSI& stack);
	CStackOSI(const CStackOSI& other);


};
